<template>
  <div class="area">
    <div class="bg">
      <div class="content" v-show="dataShow">
        <div class="th">全国风险地区汇总</div>
        <template v-if="high.length > 0">
          <div class="title">
            <img src="../../assets/images/high.png" alt="">
            高风险区{{ high.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in high" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>
        <!-- 中风险 -->
        <template v-if="mid.length > 0">
          <div class="title">
            <img src="../../assets/images/mid.png" alt="">
            中风险区{{ mid.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in mid" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>
      </div>
      <!-- 没有数据提示-->
        <div class="tips" v-if="tipShow">
          <img src="../../assets/images/nullimg/null1.png" width="100%" alt="">
          <p class="tip_one">{{tip}}</p>
          <p class="tip_two">Sorry. there is no date.</p>
          <div class="tipback" @click="tipBack">返回</div>
        </div>
    </div>
  </div>
</template>

<script>
import api from "../../api";

export default {
  data() {
    return {
      high: [], //高风险区数据
      mid: [], //低风险区域
      tipShow:false,//有无数据提示显示/隐藏
      dataShow:false,//数据显示/隐藏
      tip:''// 提示
    };
  },
  methods: {
    tipBack() {
      this.$router.back()
    }
  },
  created() {
    console.log(this.high.length);
    api.getCovInfo().then((res) => {
      console.log(res.data);
      let riskarea = res.data.newslist[0].riskarea;

      // 判断是否有汉字
      var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
      //解析
      if (riskarea != null && !reg.test(riskarea)) {
        this.high = riskarea.high;
        this.mid = riskarea.mid;
        this.dataShow=true
      }else {
        this.tipShow=true
        this.tip=riskarea
      }
    });
  }
};
</script>

<style scoped>
.area {
  background: #f5f5f5;
}

.bg {
  height: 3.6rem;
  background: url("../../assets/images/area.png") no-repeat;
  background-size: cover;
  padding-top: 2.6rem;
}

.content {
  background: #fff;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
  padding: 0.2rem;
  border-radius: 0.2rem;
  min-height: 4rem;
  margin-bottom: 0.2rem;
}

.content .th {
  margin-bottom: 0.3rem;
  font-size: 0.34rem;
}

.content .th:before {
  display: inline-block;
  width: 0.1rem;
  height: 0.3rem;
  margin-right: 0.1rem;
  background-color: #4169e2;
  content: "";
  vertical-align: middle;
}

.content .title {
  font-size: 0.3rem;
  margin-bottom: 0.3rem;
}

.content .title img {
  width: 0.4rem;
  vertical-align: top;
}

.content .list li {
  margin-bottom: 0.2rem;
  color: #333;
  background: #f7f7f7;
  padding: 0.1rem;
  border-radius: 0.1rem;
  letter-spacing: 0.01rem;
  line-height: 0.5rem;
}

.tips {
  text-align: center;
  color: #424d6a;
  margin: 0 auto;
}

.tips .tip_one {
  font-size: 0.4rem;
  margin-bottom: 0.2rem;
}

.tips .tip_two {
  font-size: 0.3rem;
  margin-bottom: 0.35rem;
}

.tips .tipback {
  width: 2.5rem;
  height: 0.6rem;
  line-height: 0.6rem;
  margin: 0 auto;
  color: #fff;
  font-weight: bold;
  background-color: #fea26f;
  border-radius: 0.5rem;
}

[v-cloak] {
  display: none !important;
}
.v-enter{
  display: none;
}
.v-enter-active{
  display: none;
}

</style>
